import request from '@/utils/request'
import { getToken } from '@/utils/auth'

export function fetchList(query) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/proceeds/getProceeds',
    method: 'get',
    params: query
  })
}

export function getProceedsSum(query) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/proceeds/getProceedsSum',
    method: 'get',
    params: query
  })
}

export function distributorList() {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/proceeds/selectDistributor',
    method: 'get',
    params: null
  })
}

export function addProceeds(data) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/proceeds/addProceeds',
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data
  })
}

export function getGoodsList(data) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/proceeds/selectByproceedId/' + data,
    method: 'get',
    params: null
  })
}

export function addProcurementDetails(data) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/proceeds/addProcurementDetails',
    method: 'post',
    data
  })
}

export function paymentList(query) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/payment/getPayment',
    method: 'get',
    params: query
  })
}

export function getPaymentSum(query) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/payment/getPaymentSum',
    method: 'get',
    params: query
  })
}

export function addPayment(data) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/payment/addPayment',
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data
  })
}

export function updatePayment(data, id) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/payment/updatePayment/' + id,
    method: 'post',
    data
  })
}
export function updateProceed(data, id) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/proceeds/updateProceeds/' + id,
    method: 'post',
    data
  })
}

export function sendSms(data) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/sms/sendSms',
    method: 'post',
    data
  })
}

export function selectGroupByDis(query) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/proceeds/selectGroupByDis',
    method: 'get',
    params: query
  })
}

export function selectBytime(starTime, endTime) {
  const data = {
    starTime,
    endTime
  }
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/proceeds/selectBytime',
    method: 'get',
    params: data
  })
}

export function selectProBytime(starTime, endTime) {
  const data = {
    starTime,
    endTime
  }
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/proceeds/selectProBytime',
    method: 'get',
    params: data
  })
}

export function selectShiBytime(starTime, endTime) {
  const data = {
    starTime,
    endTime
  }
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/proceeds/selectShiBytime',
    method: 'get',
    params: data
  })
}

export function doExportPayment(query) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/payment/exportPaymentReport',
    method: 'get',
    params: query
  })
}
export function doExportProceed(query) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/proceeds/exportProceedReport',
    method: 'get',
    params: query
  })
}
